package org.example.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.example.model.entity.VerificationCode;

@Mapper
public interface VerificationCodeMapper extends BaseMapper<VerificationCode> {
    @Select("SELECT EXISTS(SELECT 1 FROM verification_codes WHERE code = #{verificationCode} AND email = #{email} AND type = #{type} AND TIMESTAMPDIFF(MINUTE, created_at, NOW()) <= 5);")
    boolean validateVerificationCode(@Param("verificationCode") String verificationCode, @Param("email") String email,@Param("type") String type);
}
